package com.zmn.oms.api.controller.third.haobai;


import com.zmn.oms.common.exception.OmsBaseException;
import com.zmn.oms.third.haobai.service.HaobaiService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;


/**
 * 类描述：号百订单手动同步
 *  @author lianghailong
 *  @date 2020/01/16 11:39
 */
@RestController
@RequestMapping("/haobai")
@Slf4j
public class HaobaiController {

    @Autowired
    private HaobaiService haobaiService;

    /**
     * 手动触发：测试同步订单完成接口
     */
    @GetMapping("/syncComplete")
    @ResponseBody
    public String testSyncComplete(String sign, String orderId) {
        log.info("【号百】收到手动同步订单请求：orderId=[{}]", orderId);
        if (!"zmnTest666666".equals(sign)) {
            return "Who are you???";
        }

        Long orderIdLong = null;
        try {
            orderIdLong = Long.parseLong(orderId);
        } catch (Exception e) {
        }
        if (orderIdLong == null) {
            return "订单号错误！";
        }

        try {
            return haobaiService.syncOrderStatus(orderIdLong);
        } catch (OmsBaseException e) {
            log.error(e.getMessage(), e);

            return e.getMessage();
        }
    }



}
